class Solution {
    public boolean canJump(int[] nums) {
        int k=0;
        int maxlen=0;
        for(int i=0;i<=k;i++)
        {
            maxlen=Math.max(i+nums[i],maxlen);
            k=maxlen;
            if(maxlen>=nums.length-1)
            return true;
        }
        return false;
    }
}
